package server;

import java.util.ArrayList;

import client.ClientCommLocale;

import communication.ClientComm;
import communication.ComandoComm;
import communication.ServerComm;

public class ServerCommLocale implements ServerComm {
	private Server server;
	private ArrayList<ServerClientCommLocaleStream> connections;
	
	public ServerCommLocale(Server server){
		this.server = server;
		connections = new ArrayList<ServerClientCommLocaleStream>();
	}
	
	@Override
	public void connect(ClientComm client){
		ClientCommLocale cl;
		if (client instanceof ClientCommLocale) {
			cl = (ClientCommLocale)client;
			connections.add(new ServerClientCommLocaleStream(cl, server, connections.size()));
		}
	}
	
	@Override
	public void cambioTurno(String username) {
		for (int i = 0; i<connections.size(); i++){
			connections.get(i).msgToClient(ComandoComm.cambioTurno.toString() + "," + username);
		}
	}

	@Override
	public void msgToClient(String msg) {}
	@Override
	public void msgFromClient(String msg){}

	@Override
	public void close() {}

	@Override
	public void closeAll() {}
}
